package com.hongsheng.util;

/*
@Author：郭振文
@Package：com.hongsheng.util
@File：RoleSqlProvider
@Date：2023/8/17 20:07
*/

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class RoleSqlProvider {
    public static String getRoleByCondition(@Param("roleName") String roleName,
                                             @Param("department") String department) {
        return new SQL() {{
            SELECT("*");
            FROM("tb_role");
            if (roleName != null && !roleName.isEmpty()) {
                WHERE("role_name like #{roleName}");
            }
            if (department != null && !department.isEmpty()) {
                WHERE("department like #{department}");
            }
        }}.toString();
    }

}
